package com.aplink.generic.widgets.hacky;

import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class HackyDrawerLayout extends DrawerLayout {

	private boolean mIsDisallowIntercept = false;

	public HackyDrawerLayout(Context context) {
		super(context);
	}

	public HackyDrawerLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public HackyDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		if (ev.getPointerCount() > 1 && mIsDisallowIntercept) {
			requestDisallowInterceptTouchEvent(false);
			boolean handled = super.dispatchTouchEvent(ev);
			requestDisallowInterceptTouchEvent(true);
			return handled;
		} else {
			return super.dispatchTouchEvent(ev);
		}
	}

	@Override
	public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
		mIsDisallowIntercept = disallowIntercept;
		super.requestDisallowInterceptTouchEvent(disallowIntercept);
	}
}
